Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare the icons "as const" instead of strings #303

Merged
merged 5 commits into from
Aug 21, 2024
Merged

Conversation

torgeilo
Copy link
Contributor

@torgeilo torgeilo commented Aug 8, 2024

Makes it possible to separate and group the icons by type:

export type CoreIcon = `<svg ${string}class="nrk-${string}</svg>`;
export type CoreIconExpressive = `<svg ${string}class="nrk-${string}-expressive${string}</svg>`;
export type CoreIconLogo = `<svg ${string}class="nrk-logo-${string}</svg>`;
export type CoreIconBaseline<T extends CoreIcon> = T extends CoreIconExpressive ? never : T extends CoreIconLogo ? never : T;

It's not...perfect, but it allows for some basic type safety. Then we can drop import * which breaks tree shaking in nrk-tv-web.

@torgeilo torgeilo changed the title Declare the icons as consts instead of strings Declare the icons "as const" instead of strings Aug 8, 2024
Copy link
Member

@cristobal cristobal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

@skjalgepalg
Copy link
Collaborator

skjalgepalg commented Aug 15, 2024

Made a PR for this branch to replace custom parser with dtsLiteral from @nrk/[email protected]

#308

@skjalgepalg skjalgepalg merged commit 4a32acd into master Aug 21, 2024
1 check passed
@skjalgepalg skjalgepalg deleted the as-const-types branch August 21, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants